<template>
  <div>
    <!--面包屑导航-->
    <Breadcrumb>
      <template #firstTitle>
        <span>权限管理</span>
      </template>
      <template #secondTitle>
        <span>权限列表</span>
      </template>
    </Breadcrumb>

    <!--卡片视图-->
    <el-card class="box-card">
      <!--用户列表-->
      <el-table
        border
        stripe
        :data="rightsList">
        <el-table-column type="index"></el-table-column>
        <el-table-column prop="authName" label="权限名称"></el-table-column>
        <el-table-column prop="path" label="路径"></el-table-column>
        <el-table-column prop="level" label="权限等级">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.level === '0'">一级</el-tag>
            <el-tag type="success" v-else-if="scope.row.level === '1'">二级</el-tag>
            <el-tag type="warning" v-else>三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
  </div>
</template>

<script>
  import Breadcrumb from '@/components/common/Breadcrumb.vue'
  export default {
    name: "Rights",
    data(){
      return{
        rightsList: []
      }
    },
    components: {
      Breadcrumb
    },
    created() {
      this.getRightsList();
    },
    methods: {
      // 获取用户列表
      async getRightsList() {
        const {data: res} = await this.$http.get('rights/list');
        // console.log(res);
        if (res.meta.status !== 200) {
          this.$message.error(`获取权限列表: ${res.meta.msg}`);
          return;
        }
        this.rightsList = res.data;
      },
    }
  }
</script>

<style scoped>

</style>
